#include "main_head.h"
#include "other_head.h"
#include<windows.h>
#pragma comment(lib,"winmm.lib")
//#pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
int main()
{
	PlaySound(TEXT("BK.wav"), NULL, SND_FILENAME | SND_ASYNC);
	GLint WIDTH = 800, HEIGHT = 600;
	GLFWwindow* window = __init__(WIDTH, HEIGHT);
	while (1) {
		Shader S_Bird("vs/Bird.vs", "frag/Bird.frag");
		Shader S_BK("vs/BK.vs", "frag/BK.frag");
		Shader S_Pipe("vs/Pipe.vs", "frag/Pipe.frag");
		Shader S_Number_Left("vs/Number.vs", "frag/Number.frag");
		Shader S_Number_Right("vs/Number.vs", "frag/Number.frag");
		Shader S_End("vs/End.vs", "frag/End.frag");
		Shader S_Begin("vs/Begin.vs", "frag/Begin.frag");

		BK ourBK(S_BK.Program);
		Bird ourbird(S_Bird.Program);
		Pipe ourpipe(S_Pipe.Program);
		Number_left ournumber_left(S_Number_Left.Program);
		Number_right ournumber_right(S_Number_Right.Program);
		End ourend(S_End.Program); Begin ourbegin(S_Begin.Program);

		load_all_the_image(ourBK, ourbird, ourpipe, ournumber_left, ournumber_right, ourbegin, ourend);
		GLboolean live = 1, start = 0;
		GLfloat last_time = clock();
		while (!glfwWindowShouldClose(window))
		{
			GLfloat current_time = clock();
			if (current_time - last_time > 0.1) {
				last_time = current_time;
				glfwPollEvents();
				glClear(GL_COLOR_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);

				draw_the_main_thing_and_judge_whether_you_are_die(S_BK, ourBK, S_Bird, ourbird,
					S_Pipe, ourpipe, live, start);
				draw_the_number_and_do_you_get_the_point(S_Number_Left, ournumber_left, S_Number_Right,
					ournumber_right, ourpipe, ourbird, live);
				Check_we_begin_and_check_we_end(S_Begin, ourbegin, S_End, ourend, live, start);
				if (if_die(live, start))break;
				glfwSwapBuffers(window);
			}
		}
		unbind_all_the_thing(ourBK, ourbird, ourpipe);
		ournumber_left.burn(); ournumber_right.burn();
		if (glfwWindowShouldClose(window)) {
			glfwTerminate(); break;
		}
	}
	return 0;
}
